<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/login.css"/>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="layui.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div class="form">
			<form action="" id="form" method="post">
				<div class="title">管理后台登录</div>
				<div><input type="text" name="username" placeholder="请输入账号" /></div>
				<div style="position: relative;">
					<input class="pwd" type="password" name="password" placeholder="请输入密码" />
				</div>
				<div style="display:none;">
					<input style="width: 150px;" type="text" name="verycode" placeholder="请输入验证码" /><img src="img/admin-login-bg.jpg" class="yzm"/>
					<label>
						<input type="checkbox" name="che" />
						记住密码
					</label>
				</div>

				<input type="submit" id="" value="登录" />
			</form>
			<div class="fpwd">忘记密码？<a href="">请点这里</a></div>
		</div>
		<script type="text/javascript">
			$(function(){
				
				$(window).on('resize',function(){
					$('body').width($(window).width());
					$('body').height($(window).height());
				});

				$('#form').submit(function(e) {
					$.ajax({
						type: "POST",
						url: "user/login",
						data: new FormData($(this)[0]), // serializes the form's elements.
						cache: false,
						contentType: false,
						processData: false,
						success: function(data) {
							if(data) {
								var rel = data.rel;
								if(rel){
									layui.use('layer', function() {
										var layer = layui.layer;
						
										layer.msg(data.msg, {
											icon: 6
										},function() {
											location = "index";
										})
									})
								} else {
									layui.use('layer', function() {
										var layer = layui.layer;
										layer.msg(data.msg, {
											icon: 5
										})
									})
								}
									
							} else {
								// alert("登陆失败");
								layui.use('layer', function() {
									var layer = layui.layer;
									layer.msg('登陆失败', {
										icon: 5
									})
								})
							}
					
						}
					});
					e.preventDefault();
				});
			})
		</script>
	</body>
</html>
